/**
 * 上传图片
 * 相册，拍照
 */
import React, { Component } from "react";
import { StyleSheet } from "react-native";
import { ActionSheet } from "react-native-ui-lib";
import { isIOS } from "../../configs/platform";

export default class AddImageActionDialog extends Component {

  constructor(props) {
    super(props);
    this.state = {
      isOpen: false,
    };
  }

  show = () => {
    this.setState({ isOpen: true });
  };

  dismiss = () => {
    this.setState({ isOpen: false });
  };

  render() {
    const { isOpen } = this.state;

    return (
      <ActionSheet
        useNativeIOS={isIOS()}
        cancelButtonIndex={2}
        options={[
          {
            label: "拍照",
            onPress: () => this.props.openCamera && this.props.openCamera(),
            icon: require("../../images/s_take_pic.png"),
          },
          {
            label: "相册",
            onPress: () => this.props.openPic && this.props.openPic(),
            icon: require("../../images/s_take_album.png"),
          },
          {
            label: "取消",
            onPress: () => this.dismiss(),
          },
        ]}
        visible={isOpen}
        onDismiss={() => this.setState({ isOpen: false })}
      />
    );
  }
}


const styles = StyleSheet.create({});


